package com.twu.biblioteca;


/**
 * Created by aswathik on 6/20/14.
 */
public class DisplayUserInformation implements MenuItem {
    private String menuString;
    DisplayUserInformation() {
        menuString = "Display User Information";
    }

    @Override
    public String getMenuString() {
        return menuString;
    }

    public MenuActionResult performMenuAction(UserInterface userInterface) {
        LoginValidator loginValidator = new LoginValidator(userInterface);
        MenuActionResult menuActionResult = new MenuActionResult();
        Login currentUser = LoginValidator.getCurrentUser();
        userInterface.displayResultString(String.format("%-40s%-40s%-40s", "Name", "Email", "Phone Number"));
        userInterface.displayResultString("\n====================================================================================================");
        if ( loginValidator.getListOfUsers().containsKey(currentUser) ) {
            userInterface.displayUserInformation(loginValidator.getListOfUsers().get(currentUser));
            menuActionResult.setMenuActionDetails(true,"Successfully displayed details");
        } else {
            menuActionResult.setMenuActionDetails(false,"No details to display");
        }
        return menuActionResult;
    }
}
